package pers.fish.sso.common.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * 写点什么吧
 *
 * @author fish
 * @date 2020/1/30 16:32
 */
public class TicketUtil {

    public static final String TICKET_PREFIX = "ST-";

    public static final String TGT_PREFIX = "TGT-";

    public static String generateTicket(){
        StringBuilder sb = new StringBuilder(TICKET_PREFIX);
        String uuid = UUID.randomUUID().toString().replace("-", "");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String format = sdf.format(new Date());
        sb.append(uuid).append(format);
        return sb.toString();
    }

    public static String generateTgt(){
        StringBuilder sb = new StringBuilder(TGT_PREFIX);
        String uuid = UUID.randomUUID().toString().replace("-", "");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String format = sdf.format(new Date());
        sb.append(uuid).append(format);
        return sb.toString();
    }

}
